<?php
class WanbaOrderVo extends SzAbstractMySqlVo
{

    private $id;
    private $userId;
    private $configId;
    private $code;
    private $price;
    private $billno;
    private $orderId;
    private $time;

    /**
     * Initialize WanbaOrderVo.
     *
     * @param $id
     * @param $userId
     * @param $configId
     * @param $code
     * @param $price
     * @param $billno
     * @param $orderId
     * @param $time
     * @param boolean $isInsert default false, means for now this vo is initialized not for insert process
     * @return WanbaOrderVo
     */
    public function __construct($id, $userId, $configId, $code, $price, $billno, $orderId, $time, $isInsert = false) {
        $this->id = $id;
        $this->userId = $userId;
        $this->configId = $configId;
        $this->code = $code;
        $this->price = $price;
        $this->billno = json_decode($billno, true);
        $this->orderId = json_decode($orderId, true);
        $this->time = $time;

        $this->isInsert = $isInsert;
        $this->voClassName = 'WanbaOrderVo';
        $this->ormName = 'WanbaOrder';
    }

    /**
     * @see SzAbstractVo::toArray
     */
    public function toArray($needEncode = false)
    {
        return array(
            'id' => $this->getId(),
            'userId' => $this->getUserId(),
            'configId' => $this->getConfigId(),
            'code' => $this->getCode(),
            'price' => $this->getPrice(),
            'billno' => ($needEncode) ? $this->getBillno() : $this->getRawBillno(),
            'orderId' => ($needEncode) ? $this->getOrderId() : $this->getRawOrderId(),
            'time' => $this->getTime(),
        );
    }

    /**
     * @see SzAbstractVo::toEntireArray
     */
    public function toEntireArray($needEncode = false)
    {
        return array(
            'id' => $this->getId(),
            'userId' => $this->getUserId(),
            'configId' => $this->getConfigId(),
            'code' => $this->getCode(),
            'price' => $this->getPrice(),
            'billno' => ($needEncode) ? $this->getBillno() : $this->getRawBillno(),
            'orderId' => ($needEncode) ? $this->getOrderId() : $this->getRawOrderId(),
            'time' => $this->getTime(),
        );
    }

    /**
     * @see SzAbstractVo::toPureArray
     */
    public function toPureArray()
    {
        return array(
            $this->getId(),
            $this->getUserId(),
            $this->getConfigId(),
            $this->getCode(),
            $this->getPrice(),
            $this->getBillno(),
            $this->getOrderId(),
            $this->getTime(),
        );
    }

    public function getId()
    {
        return $this->id;
    }

    public function setId($val)
    {
        $this->saveColumnStatus(0, $this->id);
        $this->id = $val;
    }

    public function getUserId()
    {
        return $this->userId;
    }

    public function setUserId($val)
    {
        $this->saveColumnStatus(1, $this->userId);
        $this->userId = $val;
    }

    public function getConfigId()
    {
        return $this->configId;
    }

    public function setConfigId($val)
    {
        $this->saveColumnStatus(2, $this->configId);
        $this->configId = $val;
    }

    public function getCode()
    {
        return $this->code;
    }

    public function setCode($val)
    {
        $this->saveColumnStatus(3, $this->code);
        $this->code = $val;
    }

    public function getPrice()
    {
        return $this->price;
    }

    public function setPrice($val)
    {
        $this->saveColumnStatus(4, $this->price);
        $this->price = $val;
    }

    public function getBillno()
    {
        return json_encode($this->billno);
    }

    public function getRawBillno()
    {
        return $this->billno;
    }

    public function setBillno($val)
    {
        $encodedLength = SzUtility::strLen(json_encode($val));
        if ($encodedLength > 25600) {
            SzLogger::get()->error('[WanbaOrderVo] The length of column billno exceed the limit, length / limit: ' . $encodedLength . ' / 25600');
            throw new SzException(10522, array('WanbaOrderVo', '25600', $encodedLength));
        } else if ($encodedLength > 23040) {
            SzLogger::get()->warn('[WanbaOrderVo] The length of column billno exceed the warning level, length / limit: ' . $encodedLength . ' / 25600');
        }
        $this->saveColumnStatus(5, $this->billno);
        $this->billno = $val;
    }

    public function getOrderId()
    {
        return json_encode($this->orderId);
    }

    public function getRawOrderId()
    {
        return $this->orderId;
    }

    public function setOrderId($val)
    {
        $encodedLength = SzUtility::strLen(json_encode($val));
        if ($encodedLength > 25600) {
            SzLogger::get()->error('[WanbaOrderVo] The length of column orderId exceed the limit, length / limit: ' . $encodedLength . ' / 25600');
            throw new SzException(10522, array('WanbaOrderVo', '25600', $encodedLength));
        } else if ($encodedLength > 23040) {
            SzLogger::get()->warn('[WanbaOrderVo] The length of column orderId exceed the warning level, length / limit: ' . $encodedLength . ' / 25600');
        }
        $this->saveColumnStatus(6, $this->orderId);
        $this->orderId = $val;
    }

    public function getTime()
    {
        return $this->time;
    }

    public function setTime($val)
    {
        $this->saveColumnStatus(7, $this->time);
        $this->time = $val;
    }

}